/**
 * OpenAction.java
 * @author: liuex
 * 2007-12-28 ����10:15:16
 *
 * note: 
 */
package org.lex.explorer.file;

import java.awt.event.ActionEvent;
import java.io.File;

public class NewFolderAction extends AbstractFileAction {

	public NewFolderAction(FileExplorer fileExplorer) {
		super(fileExplorer);
		this.setName("New folder");
	}

	public void doInBackground(ActionEvent e) {
		String name = this.input("New folder", "Enter folder name:", "New Folder");
		if (null == name)
			return;
		File folder = new File(this.fileExplorer.getDirectory(), name);
		if (true == folder.exists() && folder.isDirectory()) {
			this.error("Folder exists", "Can not create folder: " + name);
			return;
		} else {
			try {
				folder.mkdirs();
				fileExplorer.refresh();
			} catch (Exception ex) {
				this.error("Create folder error", ex.getLocalizedMessage());
			}
		}
	}
}
